<?php
declare (strict_types = 1);

namespace app\admin\middleware;

use app\admin\model\Admin;
use think\exception\HttpException;
use think\facade\View;

class Login
{
    /**
     * 处理请求
     *
     * @param \think\Request $request
     * @param \Closure       $next
     * @return Response
     */
    public function handle($request, \Closure $next)
    {
        try {
            if (!session('name') && !cache('userLogin')){
                return redirect('/login/login');
            }
            return $next($request);
        } catch (HttpException $exception){
            return success($exception->getStatusCode(),$exception->getMessage());
        }
    }
}
